﻿<%@ Page Title="" Language="C#" MasterPageFile="~/manager/page/ManagerMasterPage.Master" AutoEventWireup="true" CodeBehind="article3.aspx.cs" Inherits="Com.Web.coffinegurunaru.manager.board.article3" %>
<%@ Register TagPrefix="UC" TagName="BoardMenu" Src="~/manager/board/boardmenu.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phContent" runat="server">
<hr />
<br />
<table>
<tr>
	<td valign="top">
        <UC:BoardMenu id="boardMenu" runat="server" />
	</td>
	<td style="width:20px;"></td>
	<td valign="top">
		<div id="m_Input">
		<table cellpadding="0" cellspacing="1" border="0" style="background-color:Olive">
		<tr>
			<td style="width:100px; background-color:#eeeeee; text-align:center;">제목</td>
			<td style="width:500px; background-color:#ffffff; text-align:left;"><input type="text" class="m_Title" size="70" /></td>
		</tr>
		<tr>
			<td style="background-color:#eeeeee; text-align:center;">내용</td>
			<td style="background-color:#ffffff; text-align:left;"><textarea class="m_Content" rows="8" cols="80"></textarea></td>
		</tr>
		<tr>
			<td colspan="2" style="background-color:#ffffff; text-align:center;"><input type="button" value="저장" class="m_btnCreate"/></td>
		</tr>
		</table>
		</div>
		<br />
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td style="text-align:center;" valign="top">
				<div id="m_List"></div>
				<br />
				<div id="m_Pager"></div>			
			</td>
		</tr>
		</table>
	</td>
</tr>
</table>



<script language="javascript" type="text/javascript">
(function($) {
	$.Article3 = {};
	
	$.Article3 = {
		BoardSN : <%=BoardSN %>,

		Init : function() {
			$("#m_Pager").pager({
				pageSize : 20,
				useCallback : true,
				currentPageNo : 1,
				callback:function(pageNo) {
					$.Article3.GetList();
				}
			});
			
			$("#m_Input input.m_btnCreate").click(function() {
				$.Article3.Create();
				return false;
			});

			$.Article3.GetList();
		},
		
		GetList : function() {
			$("#m_List").ajaxNet(
			"/manager/board/boardMethod.aspx?_vb=GetListArticle3" ,
			{
				"BoardSN" : $.Article3.BoardSN
			,	"PageNo" : $("#m_Pager").pager("option", "currentPageNo")
			,	"PageSize" : $("#m_Pager").pager("option", "pageSize")
			,	"Title_Search" : "" 
			}, function(results, context)
			{
				$("#m_List").html( results[ 0 ] );
				$("#m_List").find("input.m_btnInfo, a.m_btnInfo").click(function() {
					var $tr = $(this).closest("tr");
					$.Article3.GetInfo($tr);
				});
				$("#m_List").find("input.m_btnModify").click(function() {
					var $tr = $(this).closest("tr.m_ArticleInfo");
					$.Article3.Modify($tr);
				});
				$("#m_List").find("input.m_btnRemove").click(function() {
					var $tr = $(this).closest("tr");
					var data = $tr.tagdata();
					$.Article3.Remove(data.ArticleSN);
				});
				$("#m_Pager").pager("update", results[1]);
			});
		},
		
		GetInfo : function($tr) {
			var data = $tr.tagdata();
			var ArticleSN = data.ArticleSN;
			$tr.parent().find("tr.m_ArticleInfo").hide();
			$tr.parent().find("tr.m_ArticleInfo_" + ArticleSN).show();
		},
		
		Create : function() {
			var Title = $("#m_Input input.m_Title").val();
			var Content = $("#m_Input textarea.m_Content").val();
			
			if ( $.trim(Title) == "" ) {
				alert( "제목을 입력하세요");
				return false;
			}
			
			if ( $.trim(Content) == "" ) {
				alert( "내용을 입력하세요");
				return false;
			}
			
			$("#m_Input").ajaxNet(
			"/manager/board/boardMethod.aspx?_vb=CreateArticle" ,
			{
				"BoardSN" : $.Article3.BoardSN
			,	"Title" : Title
			,	"Content" : Content
			,	"JsonData" : ""
			,	"FileUrl" : ""
			}, function(results, context)
			{
				$("#m_Input input.m_Title").val("");
				$("#m_Input textarea.m_Content").val("");
				$("#m_Pager").pager("option", "currentPageNo", 1);
				$.Article3.GetList();
			});
		},
		
		Modify : function($tr) {
			var data = $tr.tagdata();
			var ArticleSN = data.ArticleSN;
			var Title = $tr.find("input.m_Title").val();
			var Content = $tr.find("textarea.m_Content").val();

			$tr.ajaxNet(
			"/manager/board/boardMethod.aspx?_vb=ModifyArticle" ,
			{
				"ArticleSN" : ArticleSN
			,	"Title" : Title
			,	"Content" : Content
			,	"JsonData" : ""
			,	"FileUrl" : ""
			}, function(results, context)
			{
				alert( "변경되었습니다.");
				$.Article3.GetList();
			});
		},
		
		Remove : function(ArticleSN, isEmpty) {
			if ( confirm("정말로 삭제하시겠습니까?") ) {
				$("#m_Info").ajaxNet(
				"/manager/board/boardMethod.aspx?_vb=RemoveArticle" ,
				{
					"ArticleSN" : ArticleSN
				}, function(results, context)
				{
					$.Article3.GetList();
				});
			}
		}
	}
	
	$(function() {
		$.Article3.Init();
	});
})(jQuery);
</script>


</asp:Content>
